package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.SmsBanner;
import com.juneng.mapper.SmsBannerMapper;
import com.juneng.service.ISmsBannerService;
import com.juneng.dto.SmsBannerDto;
import com.juneng.dto.SmsBannerQueryDto;
import com.juneng.vo.SmsBannerVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 *  服务实现类
 *
 * @author zds
 * @since 2021-07-27
 */
@Service
@AllArgsConstructor
public class SmsBannerServiceImpl implements ISmsBannerService {

    protected SmsBannerMapper smsBannerMapper;
    @Override
    public IPage<SmsBannerVo> page(SmsBannerQueryDto dto) {
        IPage<SmsBannerVo> page = Condition.getPage(dto);
        return smsBannerMapper.page(page,dto);
    }

    @Override
    public List<SmsBanner> list(SmsBannerQueryDto dto) {
        QueryWrapper<SmsBanner> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,SmsBanner.class));
        return smsBannerMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(SmsBannerDto dto) {
        return smsBannerMapper.insert(BeanCopyUtils.copy(dto,SmsBanner.class));
    }

    @Override
    public Integer updateById(SmsBannerDto dto) {
        return smsBannerMapper.updateById(BeanCopyUtils.copy(dto,SmsBanner.class));
    }

    @Override
    public Integer deleteLogic(Long id) {
        return smsBannerMapper.deleteById(id);
    }

    @Override
    public SmsBanner getById(Long id) {
        return smsBannerMapper.selectById(id);
    }
}
